package com.example.controller;

import com.example.annotation.PassToken;
import com.example.domain.User;
import com.example.service.UserService;
import com.example.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {
    @Resource
    private UserService userService;

    @PostMapping("/doLogin")
    @PassToken
    private Result login(@RequestBody User user) {
        String token = userService.login(user);
        return Result.success(token);
    }


    @GetMapping("/list")
    public Result list() {
        List<User> list = userService.list();
        return Result.success(list);
    }
}
